package com.ram.controller;

import com.ram.pojo.Asset;
import com.ram.pojo.Result;
import com.ram.service.AssetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/asset")
public class AssetController {
    @Autowired
    private AssetService assetService;

    @GetMapping("/list")
    public Result list() {
        return Result.success(assetService.list());
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        return Result.success(assetService.getById(id));
    }

    @PostMapping
    public Result add(@RequestBody Asset asset) {
        assetService.add(asset);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody Asset asset) {
        assetService.update(asset);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        assetService.deleteById(id);
        return Result.success();
    }
} 